home *** CD-ROM | disk | FTP | other *** search
- /*
- ** Apple Macintosh Developer Technical Support
- **
- ** DirectoryCopy: A robust, general purpose directory copy routine.
- **
- ** by Jim Luther, Apple Developer Technical Support Emeritus
- **
- ** File: DirectoryCopy.h
- **
- ** Copyright © 1992-1995 Apple Computer, Inc.
- ** All rights reserved.
- **
- ** You may incorporate this sample code into your applications without
- ** restriction, though the sample code has been provided "AS IS" and the
- ** responsibility for its operation is 100% yours. However, what you are
- ** not permitted to do is to redistribute the source as "DSC Sample Code"
- ** after having made changes. If you're going to re-distribute the source,
- ** we require that you make it clear in the source that the code was
- ** descended from Apple Sample Code, but that you've made changes.
- */
-
- #ifndef __DIRECTORYCOPY__
- #define __DIRECTORYCOPY__
-
- #include <Types.h>
- #include <Files.h>
-
- #ifdef __cplusplus
- extern "C" {
- #endif
-
- /*****************************************************************************/
-
- enum
- {
- getNextItemOp = 1, /* couldn't access items in this directory - no access privileges */
- copyDirCommentOp = 2, /* couldn't copy directory's Finder comment */
- copyDirAccessPrivsOp = 3, /* couldn't copy directory's AFP access privileges */
- copyDirFMAttributesOp = 4, /* couldn't copy directory's File Manager attributes */
- dirCreateOp = 5, /* couldn't create destination directory */
- fileCopyOp = 6 /* couldn't copy file */
- };
-
- /*****************************************************************************/
-
- typedef pascal Boolean (*CopyErrProcPtr) (OSErr error,
- short failedOperation,
- short srcVRefNum,
- long srcDirID,
- StringPtr srcName,
- short dstVRefNum,
- long dstDirID,
- StringPtr dstName);
- /* ¶ Prototype for the CopyErrProc function DirectoryCopy calls.
- This is the prototype for the CopyErrProc function DirectoryCopy
- calls if an error condition is detected sometime during the copy. If
- CopyErrProc returns true, then DirectoryCopy attempts to continue with
- the directory copy operation. If CopyErrProc returns false, then
- DirectoryCopy stops the directory copy operation.
-
- error input: The error result code that caused CopyErrProc to
- be called.
- failedOperation input: The operation that returned an error to
- DirectoryCopy.
- srcVRefNum input: Source volume specification.
- srcDirID input: Source directory ID.
- srcName input: Source file or directory name, or nil if
- srcDirID specifies the directory.
- dstVRefNum input: Destination volume specification.
- dstDirID input: Destination directory ID.
- dstName input: Destination file or directory name, or nil if
- dstDirID specifies the directory.
-
- __________
-
- Also see: DirectoryCopy, FSpDirectoryCopy
- */
-
- #define CallCopyErrProc(userRoutine, error, failedOperation, srcVRefNum, srcDirID, srcName, dstVRefNum, dstDirID, dstName) \
- (*(userRoutine))((error), (failedOperation), (srcVRefNum), (srcDirID), (srcName), (dstVRefNum), (dstDirID), (dstName))
-
- /*****************************************************************************/
-
- pascal OSErr DirectoryCopy(short srcVRefNum,
- long srcDirID,
- StringPtr srcName,
- short dstVRefNum,
- long dstDirID,
- StringPtr dstName,
- void *copyBufferPtr,
- long copyBufferSize,
- Boolean preflight,
- CopyErrProcPtr copyErrHandler);
- /* ¶ Make a copy of a directory structure in a new location.
- The DirectoryCopy function makes a copy of a directory structure in a
- new location. If copyBufferPtr <> NIL, it points to a buffer of
- copyBufferSize that is used to copy files data. The larger the
- supplied buffer, the faster the copy. If copyBufferPtr = NIL, then this
- routine allocates a buffer in the application heap. If you pass a
- copy buffer to this routine, make its size a multiple of 512
- ($200) bytes for optimum performance.
-
- srcVRefNum input: Source volume specification.
- srcDirID input: Source directory ID.
- srcName input: Source directory name, or nil if
- srcDirID specifies the directory.
- dstVRefNum input: Destination volume specification.
- dstDirID input: Destination directory ID.
- dstName input: Destination directory name, or nil if
- dstDirID specifies the directory.
- copyBufferPtr input: Points to a buffer of copyBufferSize that
- is used the i/o buffer for the copy or
- nil if you want DirectoryCopy to allocate its
- own buffer in the application heap.
- copyBufferSize input: The size of the buffer pointed to
- by copyBufferPtr.
- preflight input: If true, DirectoryCopy makes sure there are
- enough allocation blocks on the destination
- volume to hold the directory's files before
- starting the copy.
- copyErrHandler input: A pointer to the routine you want called if an
- error condition is detected during the copy, or
- nil if you don't want to handle error conditions.
- Error handling is recommended...
-
- __________
-
- Also see: CopyErrProcPtr, FSpDirectoryCopy, FileCopy, FSpFileCopy
- */
-
- /*****************************************************************************/
-
- pascal OSErr FSpDirectoryCopy(const FSSpec *srcSpec,
- const FSSpec *dstSpec,
- void *copyBufferPtr,
- long copyBufferSize,
- Boolean preflight,
- CopyErrProcPtr copyErrHandler);
- /* ¶ Make a copy of a directory structure in a new location.
- The FSpDirectoryCopy function makes a copy of a directory structure in a
- new location. If copyBufferPtr <> NIL, it points to a buffer of
- copyBufferSize that is used to copy files data. The larger the
- supplied buffer, the faster the copy. If copyBufferPtr = NIL, then this
- routine allocates a buffer in the application heap. If you pass a
- copy buffer to this routine, make its size a multiple of 512
- ($200) bytes for optimum performance.
-
- srcSpec input: An FSSpec record specifying the directory to copy.
- dstSpec input: An FSSpec record specifying destination directory
- of the copy.
- copyBufferPtr input: Points to a buffer of copyBufferSize that
- is used the i/o buffer for the copy or
- nil if you want DirectoryCopy to allocate its
- own buffer in the application heap.
- copyBufferSize input: The size of the buffer pointed to
- by copyBufferPtr.
- preflight input: If true, FSpDirectoryCopy makes sure there are
- enough allocation blocks on the destination
- volume to hold the directory's files before
- starting the copy.
- copyErrHandler input: A pointer to the routine you want called if an
- error condition is detected during the copy, or
- nil if you don't want to handle error conditions.
- Error handling is recommended...
-
- __________
-
- Also see: CopyErrProcPtr, DirectoryCopy
- */
-
- /*****************************************************************************/
-
- #ifdef __cplusplus
- }
- #endif
-
- #endif /* __DIRECTORYCOPY__ */
-